<script>
	export default {
		data() {
			return {
				param: {
					longitude: '',
					latitude: '',
				}
			};
		},
		onLaunch: function() {
			let _this = this;
			uni.startLocationUpdate();
			uni.onLocationChange(function(res) {

				console.log('经度：' + res.longitude);
				console.log('纬度：' + res.latitude);
				let param = {
					"longitude": res.longitude,
					"latitude": res.latitude,
				}
				//我的Geo坐标是在开始接单的时候，持续的更新的，如果是停止接单那么不需要更新Geo
				if (uni.getStorageSync("workStatus") == "开始接单") {
					_this.post("/driver/app/driver/driverLocation2Geo", param, (result) => {
						let {
							message,
							success
						} = result.data;
						//如果成功了 什么都不用作 没成功需要提示用户
						if (!success) {
							uni.showToast({
								duration: 2000,
								icon: "error",
								title: "Geo存储失败",
							})
						}
					})
				} else {
					uni.showToast({
						duration: 2000,
						icon: "error",
						title: message,
					})
				}

			});

		},
		methods: {

		},
		onShow: function() {},
		onHide: function() {}
	};
</script>

<style lang="scss">
	@import 'uview-ui/index.scss';
</style>